#include <iostream>

using namespace std;


class binaryTreeNode
{
	public:
	int element;
	binaryTreeNode* leftChild;
	binaryTreeNode* rightChild; 
	binaryTreeNode() { leftChild=rightChild = NULL; }  
	binaryTreeNode(int theElement) { element = theElement; leftChild=rightChild=NULL;}
	binaryTreeNode(int theElement,binaryTreeNode*theleftChild,binaryTreeNode*therightChild)  { element = theElement; leftChild=theleftChild;rightChild=therightChild; }
};

binaryTreeNode* getpostOrder( int n,char* a,char* b)
{
	if(n==0)
	{
		return NULL;
	}
	binaryTreeNode* root=new binaryTreeNode(0,NULL,NULL);
	root->element=a[0]-48;
	int rootpos=0;
	for(;rootpos<n;rootpos++)
	{
		if(*a ==b[rootpos])
		   break;
	} 
	
	if (*(a+1)!='a'&&*(b)!='b') 
	{root->leftChild=getpostOrder(rootpos,a+1,b);}
	if(*(a+rootpos+1)!='a'&&*(b+rootpos+1)!='b')
	{root->rightChild=getpostOrder(n-(rootpos+1),a+rootpos+1,b+rootpos+1);}
	return root;
	
}



void postOrder(binaryTreeNode* t) 
{
	if(t==NULL)
	  return;
	postOrder (t->leftChild);
	postOrder (t->rightChild);
	cout<<t->element<<" ";
}


int main()
{
	int n=0;
	cin>>n;
	char a[100],b[100];
	for(int i=0;i<100;i++)
	 { a[i]='a'; }
	 for(int i=0;i<100;i++)
	 	 { b[i]='b'; }
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	binaryTreeNode* post;
	post=getpostOrder(n,a,b);
	postOrder(post);
	
	
	
} 
